package com.jianganming.transparent;

import com.alibaba.fastjson.JSONObject;

//组合模式（树型设计）
public class Test {
    public static void main(String[]args){
        Component component = new Composite("系统管理");
        Component component_1 = new Composite("用户管理");
        Component component_2 = new Composite("角色管理");

        component.addChild(component_1);
        component.addChild(component_2);
        Component component_1_1 = new Composite("查询用户");
        Component component_1_2 = new Composite("新增用户");
        Component component_1_3 = new Composite("修改用户");
        Component component_1_4 = new Composite("删除用户");
        component_1.addChild(component_1_1);
        component_1.addChild(component_1_2);
        component_1.addChild(component_1_3);
        component_1.addChild(component_1_4);

        Component component_2_1 = new Composite("查询角色");
        Component component_2_2 = new Composite("新增角色");
        Component component_2_3 = new Composite("修改角色");
        Component component_2_4 = new Composite("删除角色");
        component_2.addChild(component_2_1);
        component_2.addChild(component_2_2);
        component_2.addChild(component_2_3);
        component_2.addChild(component_2_4);


        Component component_1_1_1 = new Composite("查询普通用户");
        Component component_1_1_2 = new Composite("查询会员用户");
        component_1_1.addChild(component_1_1_1);
        component_1_1.addChild(component_1_1_2);

       // System.out.println(component.operation(""));

        Object o = JSONObject.toJSON(component);
        System.out.println(o);
    }
}
